<?php

class Default_ArticleController extends Zend_Controller_Action
{

    public function init()
    {
        $layoutPath = APPLICATION_PATH . '/templates/default';
		$options = array (
				'layout' => 'index',
				'layoutPath' => $layoutPath 
		);
		Zend_Layout::startMvc ( $options );
    }

    public function indexAction()
    {
    	
    	$page = $this->getRequest ()->getParam ( 'page' );
		list ( $this->view->Pager, $this->view->Articles ) = Article::getAll ( array (
				'a.status=?' => 1,'c.type!=?'=>1
		), $page );
    	$this->view->Categories = Categories::getAllWithoutPager(array('status=?'=>1,'type!=?'=>1));
    	
    }
    public function categoriesAction()
    {
    	$title= $this->getRequest()->getParam('id');
    	$Categories = Categories::getByNamePlain($title);
    	if($Categories){
    		$page = $this->getRequest()->getParam('page');
    		list($this->view->Pager,$this->view->Articles)=Article::getAll(array('status=?'=>1,'categories_id=?'=>$Categories->id),$page);
    		print_r($this->view->Articles->count());die();
    	}else{
    		$this->_redirect('.');
    	}
    	$this->view->Categories = Categories::getAllWithoutPager(array('status=?'=>1));
    	 
    }
    public function detailAction()
    {
    	 
    }


}

